IF EXISTS (SELECT 1
          FROM SYSOBJECTS
          WHERE  id = OBJECT_ID('USP_GetOnlineStaff')
          AND TYPE IN ('P','PC'))
   DROP PROCEDURE USP_GetOnlineStaff
GO

/****** Object:  StoredProcedure [dbo].[USP_GetOnlineStaff]    Script Date: 10/20/2010 15:51:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Boonyarit
-- Create date: 26/11/2010
-- exec[USP_GetOnlineStaff]
-- =============================================
CREATE PROCEDURE [dbo].[USP_GetOnlineStaff]
	-- Add the parameters for the stored procedure here
	@staff_code int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	select top 1 * from staff_online 
	where staff_code = @staff_code and active = 1
	order by last_update_datetime desc

END

GO
